package com.yidu.t299.service.ljc.impl;
import com.yidu.t299.dao.ljc.StockcopyMapper;
import com.yidu.t299.domain.ljc.Stockcopy;
import com.yidu.t299.service.ljc.StockcopyBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * @author 刘建常
 * @version 1.0
 * @description
 * @date:2023/3/8 10:53
 */
@Service
@Transactional
public class StockcopyBizImpl implements StockcopyBiz {
    @Autowired
    private StockcopyMapper stockcopyMapper;

    @Override
    public int deleteByPrimaryKey(Integer inputStockId) {
        return stockcopyMapper.deleteByPrimaryKey(inputStockId);
    }

    @Override
    public int insert(Stockcopy record) {
        return stockcopyMapper.insert(record);
    }

    @Override
    public Stockcopy selectByPrimaryKey(Integer inputStockId) {
        return stockcopyMapper.selectByPrimaryKey(inputStockId);
    }

    @Override
    public List<Stockcopy> selectByPage(int rows, int page, String condition) {
        return stockcopyMapper.selectByPage(rows, page, condition);
    }

    @Override
    public int selectCount(String condition) {
        return stockcopyMapper.selectCount(condition);
    }

    @Override
    public int updateByPrimaryKey(Stockcopy record) {
        return stockcopyMapper.updateByPrimaryKey(record);
    }

    @Override
    public String getCondition(Stockcopy record) {
        // 定义条件字符串变量，初始值为空格字符串
        String condition = " ";
        // 如果校区对象为空，则直接返回空条件字符串
        if (record == null) {
            return condition;
        }
        // 如果校区编号不为空(如果是基本类型就直接判断!=0)
        if (record.getInputStockId() != null) {
            condition += " and input_stock_id = " + record.getInputStockId();
        }
        // 如果校区名称不为空
        if (record.getAuthor() != null && record.getAuthor().trim().length() != 0) {
            condition += " and author like '%" + record.getAuthor() + "%'";
        }

        if (record.getTextbookName() != null && record.getAuthor().trim().length() != 0) {
            condition += " and textbook_name = " + record.getTextbookName();
        }

        if (record.getProvider() != null && record.getProvider().trim().length() != 0) {
            condition += " and provider like '%" + record.getProvider() + "%'";
        }

        if (record.getInputStockRelation() != null && record.getInputStockRelation().trim().length() != 0) {
            condition += " and input_stock_relation = " + record.getInputStockRelation() + "%'";
        }

        if (record.getInputStockTime() != null && record.getInputStockTime().trim().length() != 0) {
            condition += " and input_stock_time = " + record.getInputStockTime() + "%'";
        }

        if (record.getTextbookPrice() != null && record.getTextbookPrice().trim().length() != 0) {
            condition += " and textbook_price = " + record.getTextbookPrice() + "%'";
        }

        if (record.getPublishingCompany() != null && record.getPublishingCompany().trim().length() != 0) {
            condition += " and publishing_company = " + record.getPublishingCompany() + "%'";
        }

        if (record.getInputStockNum() != null) {
            condition += " and input_stock_num = " + record.getInputStockNum() + "%'";
        }

        if (record.getRecordId() != null) {
            condition += " and record_id = " + record.getRecordId();
        }
        // 返回条件字符串
        return condition;
    }

}
